﻿
namespace ATA.Windows.Forms
{
	/// <summary>
	/// abstract KhachHang typed datagridview
	/// </summary>
	[System.ComponentModel.DesignerCategoryAttribute("code")]
	public abstract class KhachHangDataGridViewBase : System.Windows.Forms.UserControl
	{	
		/// <summary> 
		/// Thrown when the current Entity changed.
		/// </summary>
		public event System.EventHandler<KhachHangDataGridViewEventArgs> CurrentEntityChanged;
		
		#region Fields
				
		/// <summary> 
		/// the current entity.
		/// </summary>
		private Entities.KhachHang _currentKhachHang = null;
		//private Dictionary<string, string> _columnsHeaders = new Dictionary<string, string>();
		
		/// <summary> 
		/// the datagridview instance
		/// </summary>
		protected System.Windows.Forms.DataGridView uxKhachHangDataGridView;
		
		/// <summary> 
		/// the errorprovider
		/// </summary>
		protected System.Windows.Forms.ErrorProvider uxKhachHangErrorProvider;
		
		/// <summary> 
		/// the bindingsource
		/// </summary>
		protected System.Windows.Forms.BindingSource uxKhachHangBindingSource;
		
		
		/// <summary> 
		/// the DGV column associated with the KhachHangId property
		/// </summary>
		protected System.Windows.Forms.DataGridViewTextBoxColumn uxKhachHangIdDataGridViewColumn;
		
		/// <summary> 
		/// the DGV column associated with the TenKh property
		/// </summary>
		protected System.Windows.Forms.DataGridViewTextBoxColumn uxTenKhDataGridViewColumn;
		
		/// <summary> 
		/// the DGV column associated with the GioiTinh property
		/// </summary>
		protected System.Windows.Forms.DataGridViewTextBoxColumn uxGioiTinhDataGridViewColumn;
		
		/// <summary> 
		/// the DGV column associated with the NgaySinh property
		/// </summary>
		protected System.Windows.Forms.DataGridViewTextBoxColumn uxNgaySinhDataGridViewColumn;
		
		/// <summary> 
		/// the DGV column associated with the MaKh property
		/// </summary>
		protected System.Windows.Forms.DataGridViewTextBoxColumn uxMaKhDataGridViewColumn;
		
		/// <summary> 
		/// the DGV column associated with the Cmnd property
		/// </summary>
		protected System.Windows.Forms.DataGridViewTextBoxColumn uxCmndDataGridViewColumn;
		
		/// <summary> 
		/// the DGV column associated with the NgayCap property
		/// </summary>
		protected System.Windows.Forms.DataGridViewTextBoxColumn uxNgayCapDataGridViewColumn;
		
		/// <summary> 
		/// the DGV column associated with the NoiCap property
		/// </summary>
		protected System.Windows.Forms.DataGridViewTextBoxColumn uxNoiCapDataGridViewColumn;
		
		/// <summary> 
		/// the DGV column associated with the SoDtDk property
		/// </summary>
		protected System.Windows.Forms.DataGridViewTextBoxColumn uxSoDtDkDataGridViewColumn;
		
		/// <summary> 
		/// the DGV column associated with the SoDtCty property
		/// </summary>
		protected System.Windows.Forms.DataGridViewTextBoxColumn uxSoDtCtyDataGridViewColumn;
		
		/// <summary> 
		/// the DGV column associated with the Fax property
		/// </summary>
		protected System.Windows.Forms.DataGridViewTextBoxColumn uxFaxDataGridViewColumn;
		
		/// <summary> 
		/// the DGV column associated with the SoGpdkkd property
		/// </summary>
		protected System.Windows.Forms.DataGridViewTextBoxColumn uxSoGpdkkdDataGridViewColumn;
		
		/// <summary> 
		/// the DGV column associated with the DiaChiTt property
		/// </summary>
		protected System.Windows.Forms.DataGridViewTextBoxColumn uxDiaChiTtDataGridViewColumn;
		
		/// <summary> 
		/// the DGV column associated with the HoKhauTt property
		/// </summary>
		protected System.Windows.Forms.DataGridViewTextBoxColumn uxHoKhauTtDataGridViewColumn;
		
		/// <summary> 
		/// the DGV column associated with the ParentId property
		/// </summary>
		protected System.Windows.Forms.DataGridViewTextBoxColumn uxParentIdDataGridViewColumn;
		
		/// <summary> 
		/// the DGV column associated with the DiaChiCty property
		/// </summary>
		protected System.Windows.Forms.DataGridViewTextBoxColumn uxDiaChiCtyDataGridViewColumn;
		
		/// <summary> 
		/// the DGV column associated with the BranchId property
		/// </summary>
		protected System.Windows.Forms.DataGridViewTextBoxColumn uxBranchIdDataGridViewColumn;
		
		/// <summary> 
		/// the DGV column associated with the LoaiKh property
		/// </summary>
		protected System.Windows.Forms.DataGridViewTextBoxColumn uxLoaiKhDataGridViewColumn;
		
		/// <summary> 
		/// the DGV column associated with the MaSoHv property
		/// </summary>
		protected System.Windows.Forms.DataGridViewTextBoxColumn uxMaSoHvDataGridViewColumn;
		
		/// <summary> 
		/// the DGV column associated with the NgayDangKy property
		/// </summary>
		protected System.Windows.Forms.DataGridViewTextBoxColumn uxNgayDangKyDataGridViewColumn;
		
		#endregion
					
		#region Combo list
		
		#endregion
		
		#region Main Datasource
		
		private Entities.TList<Entities.KhachHang> _KhachHangList;
				
		/// <summary> 
		/// The list of KhachHang to be displayed in the DGV.
		/// </summary>
		[System.ComponentModel.Category("Data")]
		public Entities.TList<Entities.KhachHang> KhachHangList
		{
			get {return this._KhachHangList;}
			set
			{
				this._KhachHangList = value;
				this.uxKhachHangBindingSource.DataSource = null;
				this.uxKhachHangBindingSource.DataSource = value;
				this.uxKhachHangDataGridView.DataSource = null;
				this.uxKhachHangDataGridView.DataSource = this.uxKhachHangBindingSource;				
				//this.uxKhachHangBindingSource.ListChanged += new System.ComponentModel.ListChangedEventHandler(uxKhachHangBindingSource_ListChanged);
				this.uxKhachHangBindingSource.CurrentItemChanged += new System.EventHandler(OnKhachHangBindingSourceCurrentItemChanged);
			}
		}
		
		private void OnKhachHangBindingSourceCurrentItemChanged(object sender, System.EventArgs e)
		{
			_currentKhachHang = uxKhachHangBindingSource.Current as Entities.KhachHang;
			
			if (_currentKhachHang != null)
			{
				_currentKhachHang.Validate();
			}
			//_KhachHang.Validate();
			OnCurrentEntityChanged();
		}

		//void uxKhachHangBindingSource_ListChanged(object sender, System.ComponentModel.ListChangedEventArgs e)
		//{
			//throw new Exception("The method or operation is not implemented.");
		//}		
		
		#endregion
		
		/// <summary>
		/// Gets the currently selected <c cref="Entities.KhachHang"/> instance.
		/// </summary>
		public Entities.KhachHang SelectedKhachHang
		{
			get {return this._currentKhachHang;}
		}
		
		#region other properties
		
		/// <summary>
		/// Gets or sets a value indicating whether you have provided your own data-management operations for the DataGridView control.
		/// </summary>
		[System.ComponentModel.Category(".netTiers")]
		public bool VirtualMode
		{
			get {return this.uxKhachHangDataGridView.VirtualMode;}
			set
			{
				this.uxKhachHangDataGridView.VirtualMode = value;
			}
		}
		
		/// <summary>
		/// Gets or sets a value indicating whether the option to add rows is displayed to the user.
		/// </summary>
		[System.ComponentModel.Category(".netTiers")]
		public bool AllowUserToAddRows
		{
			get {return this.uxKhachHangDataGridView.AllowUserToAddRows;}
			set {this.uxKhachHangDataGridView.AllowUserToAddRows = value;}
		}
		
		/// <summary>
		/// Gets or sets a value indicating whether the user is allowed to delete rows from the DataGridView.
		/// </summary>
		[System.ComponentModel.Category(".netTiers")]
		public bool AllowUserToDeleteRows
		{
			get {return this.uxKhachHangDataGridView.AllowUserToDeleteRows;}
			set {this.uxKhachHangDataGridView.AllowUserToDeleteRows = value;}
		}
		
		/// <summary>
		/// Gets the <c cref="DataGridView"/> instance.
		/// </summary>
		[System.ComponentModel.Category(".netTiers")]
		public System.Windows.Forms.DataGridView DataGridView
		{
			get {return this.uxKhachHangDataGridView;}
		}
		
		/// <summary>
		/// Gets a collection that contains all the columns in the control.
		/// </summary>
		[System.ComponentModel.Category(".netTiers")]		
		[System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Visible)]
		//[System.ComponentModel.EditorAttribute("System.Windows.Forms.Design.DataGridViewColumnCollectionEditor, System.Design", typeof(System.Drawing.Design.UITypeEditor))] 
		public System.Windows.Forms.DataGridViewColumnCollection Columns
		{
			get { return this.uxKhachHangDataGridView.Columns; }
		}
		
		#endregion
		
		/// <summary> 
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.IContainer components = null;
	
		/// <summary> 
		/// Clean up any resources being used.
		/// </summary>
		/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
		protected override void Dispose(bool disposing)
		{
			if (disposing && (components != null))
			{
				components.Dispose();
			}
			base.Dispose(disposing);
		}
	
		#region Constructor
	
		/// <summary>
		/// Initializes a new instance of the <see cref="KhachHangDataGridViewBase"/> class.
		/// </summary>
		public KhachHangDataGridViewBase()
		{			
			this.components = new System.ComponentModel.Container();			
			
			this.uxKhachHangDataGridView = new System.Windows.Forms.DataGridView();
			this.uxKhachHangBindingSource = new System.Windows.Forms.BindingSource(this.components);
			this.uxKhachHangErrorProvider = new System.Windows.Forms.ErrorProvider(this.components);
			this.uxKhachHangIdDataGridViewColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
			this.uxTenKhDataGridViewColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
			this.uxGioiTinhDataGridViewColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
			this.uxNgaySinhDataGridViewColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
			this.uxMaKhDataGridViewColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
			this.uxCmndDataGridViewColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
			this.uxNgayCapDataGridViewColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
			this.uxNoiCapDataGridViewColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
			this.uxSoDtDkDataGridViewColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
			this.uxSoDtCtyDataGridViewColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
			this.uxFaxDataGridViewColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
			this.uxSoGpdkkdDataGridViewColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
			this.uxDiaChiTtDataGridViewColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
			this.uxHoKhauTtDataGridViewColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
			this.uxParentIdDataGridViewColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
			this.uxDiaChiCtyDataGridViewColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
			this.uxBranchIdDataGridViewColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
			this.uxLoaiKhDataGridViewColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
			this.uxMaSoHvDataGridViewColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
			this.uxNgayDangKyDataGridViewColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
			((System.ComponentModel.ISupportInitialize)(this.uxKhachHangDataGridView)).BeginInit();
			((System.ComponentModel.ISupportInitialize)(this.uxKhachHangBindingSource)).BeginInit();
			((System.ComponentModel.ISupportInitialize)(this.uxKhachHangErrorProvider)).BeginInit();
			this.SuspendLayout();
						
			// 
			// uxKhachHangErrorProvider
			// 
			this.uxKhachHangErrorProvider.ContainerControl = this;
			this.uxKhachHangErrorProvider.DataSource = this.uxKhachHangBindingSource;						
			// 
			// uxKhachHangDataGridView
			// 
			this.uxKhachHangDataGridView.AutoGenerateColumns = false;
			this.uxKhachHangDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
			this.uxKhachHangDataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
		this.uxKhachHangIdDataGridViewColumn,
		this.uxTenKhDataGridViewColumn,
		this.uxGioiTinhDataGridViewColumn,
		this.uxNgaySinhDataGridViewColumn,
		this.uxMaKhDataGridViewColumn,
		this.uxCmndDataGridViewColumn,
		this.uxNgayCapDataGridViewColumn,
		this.uxNoiCapDataGridViewColumn,
		this.uxSoDtDkDataGridViewColumn,
		this.uxSoDtCtyDataGridViewColumn,
		this.uxFaxDataGridViewColumn,
		this.uxSoGpdkkdDataGridViewColumn,
		this.uxDiaChiTtDataGridViewColumn,
		this.uxHoKhauTtDataGridViewColumn,
		this.uxParentIdDataGridViewColumn,
		this.uxDiaChiCtyDataGridViewColumn,
		this.uxBranchIdDataGridViewColumn,
		this.uxLoaiKhDataGridViewColumn,
		this.uxMaSoHvDataGridViewColumn,
		this.uxNgayDangKyDataGridViewColumn			});
			this.uxKhachHangDataGridView.Dock = System.Windows.Forms.DockStyle.Fill;
			this.uxKhachHangDataGridView.Location = new System.Drawing.Point(0, 0);
			this.uxKhachHangDataGridView.Name = "uxKhachHangDataGridView";
			this.uxKhachHangDataGridView.Size = new System.Drawing.Size(470, 300);
			this.uxKhachHangDataGridView.TabIndex = 0;	
			this.uxKhachHangDataGridView.BackgroundColor = System.Drawing.Color.WhiteSmoke;
			this.uxKhachHangDataGridView.EnableHeadersVisualStyles = false;
			this.uxKhachHangDataGridView.DataError += new System.Windows.Forms.DataGridViewDataErrorEventHandler(this.OnKhachHangDataGridViewDataError);
			this.uxKhachHangDataGridView.CellValueNeeded += new System.Windows.Forms.DataGridViewCellValueEventHandler(this.OnKhachHangDataGridViewCellValueNeeded);
			this.uxKhachHangDataGridView.CellValuePushed += new System.Windows.Forms.DataGridViewCellValueEventHandler(this.OnKhachHangDataGridViewCellValuePushed);
			
			//
			// uxKhachHangIdDataGridViewColumn
			//
			this.uxKhachHangIdDataGridViewColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
			this.uxKhachHangIdDataGridViewColumn.DataPropertyName = "KhachHangId";
			this.uxKhachHangIdDataGridViewColumn.HeaderText = "KhachHangId";
			this.uxKhachHangIdDataGridViewColumn.Name = "uxKhachHangIdDataGridViewColumn";
			this.uxKhachHangIdDataGridViewColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
			this.uxKhachHangIdDataGridViewColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
			this.uxKhachHangIdDataGridViewColumn.ReadOnly = false;		
			//
			// uxTenKhDataGridViewColumn
			//
			this.uxTenKhDataGridViewColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
			this.uxTenKhDataGridViewColumn.DataPropertyName = "TenKh";
			this.uxTenKhDataGridViewColumn.HeaderText = "TenKh";
			this.uxTenKhDataGridViewColumn.Name = "uxTenKhDataGridViewColumn";
			this.uxTenKhDataGridViewColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
			this.uxTenKhDataGridViewColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
			this.uxTenKhDataGridViewColumn.ReadOnly = false;		
			//
			// uxGioiTinhDataGridViewColumn
			//
			this.uxGioiTinhDataGridViewColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
			this.uxGioiTinhDataGridViewColumn.DataPropertyName = "GioiTinh";
			this.uxGioiTinhDataGridViewColumn.HeaderText = "GioiTinh";
			this.uxGioiTinhDataGridViewColumn.Name = "uxGioiTinhDataGridViewColumn";
			this.uxGioiTinhDataGridViewColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
			this.uxGioiTinhDataGridViewColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
			this.uxGioiTinhDataGridViewColumn.ReadOnly = false;		
			//
			// uxNgaySinhDataGridViewColumn
			//
			this.uxNgaySinhDataGridViewColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
			this.uxNgaySinhDataGridViewColumn.DataPropertyName = "NgaySinh";
			this.uxNgaySinhDataGridViewColumn.HeaderText = "NgaySinh";
			this.uxNgaySinhDataGridViewColumn.Name = "uxNgaySinhDataGridViewColumn";
			this.uxNgaySinhDataGridViewColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
			this.uxNgaySinhDataGridViewColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
			this.uxNgaySinhDataGridViewColumn.ReadOnly = false;		
			//
			// uxMaKhDataGridViewColumn
			//
			this.uxMaKhDataGridViewColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
			this.uxMaKhDataGridViewColumn.DataPropertyName = "MaKh";
			this.uxMaKhDataGridViewColumn.HeaderText = "MaKh";
			this.uxMaKhDataGridViewColumn.Name = "uxMaKhDataGridViewColumn";
			this.uxMaKhDataGridViewColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
			this.uxMaKhDataGridViewColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
			this.uxMaKhDataGridViewColumn.ReadOnly = false;		
			//
			// uxCmndDataGridViewColumn
			//
			this.uxCmndDataGridViewColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
			this.uxCmndDataGridViewColumn.DataPropertyName = "Cmnd";
			this.uxCmndDataGridViewColumn.HeaderText = "Cmnd";
			this.uxCmndDataGridViewColumn.Name = "uxCmndDataGridViewColumn";
			this.uxCmndDataGridViewColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
			this.uxCmndDataGridViewColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
			this.uxCmndDataGridViewColumn.ReadOnly = false;		
			//
			// uxNgayCapDataGridViewColumn
			//
			this.uxNgayCapDataGridViewColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
			this.uxNgayCapDataGridViewColumn.DataPropertyName = "NgayCap";
			this.uxNgayCapDataGridViewColumn.HeaderText = "NgayCap";
			this.uxNgayCapDataGridViewColumn.Name = "uxNgayCapDataGridViewColumn";
			this.uxNgayCapDataGridViewColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
			this.uxNgayCapDataGridViewColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
			this.uxNgayCapDataGridViewColumn.ReadOnly = false;		
			//
			// uxNoiCapDataGridViewColumn
			//
			this.uxNoiCapDataGridViewColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
			this.uxNoiCapDataGridViewColumn.DataPropertyName = "NoiCap";
			this.uxNoiCapDataGridViewColumn.HeaderText = "NoiCap";
			this.uxNoiCapDataGridViewColumn.Name = "uxNoiCapDataGridViewColumn";
			this.uxNoiCapDataGridViewColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
			this.uxNoiCapDataGridViewColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
			this.uxNoiCapDataGridViewColumn.ReadOnly = false;		
			//
			// uxSoDtDkDataGridViewColumn
			//
			this.uxSoDtDkDataGridViewColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
			this.uxSoDtDkDataGridViewColumn.DataPropertyName = "SoDtDk";
			this.uxSoDtDkDataGridViewColumn.HeaderText = "SoDtDk";
			this.uxSoDtDkDataGridViewColumn.Name = "uxSoDtDkDataGridViewColumn";
			this.uxSoDtDkDataGridViewColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
			this.uxSoDtDkDataGridViewColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
			this.uxSoDtDkDataGridViewColumn.ReadOnly = false;		
			//
			// uxSoDtCtyDataGridViewColumn
			//
			this.uxSoDtCtyDataGridViewColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
			this.uxSoDtCtyDataGridViewColumn.DataPropertyName = "SoDtCty";
			this.uxSoDtCtyDataGridViewColumn.HeaderText = "SoDtCty";
			this.uxSoDtCtyDataGridViewColumn.Name = "uxSoDtCtyDataGridViewColumn";
			this.uxSoDtCtyDataGridViewColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
			this.uxSoDtCtyDataGridViewColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
			this.uxSoDtCtyDataGridViewColumn.ReadOnly = false;		
			//
			// uxFaxDataGridViewColumn
			//
			this.uxFaxDataGridViewColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
			this.uxFaxDataGridViewColumn.DataPropertyName = "Fax";
			this.uxFaxDataGridViewColumn.HeaderText = "Fax";
			this.uxFaxDataGridViewColumn.Name = "uxFaxDataGridViewColumn";
			this.uxFaxDataGridViewColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
			this.uxFaxDataGridViewColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
			this.uxFaxDataGridViewColumn.ReadOnly = false;		
			//
			// uxSoGpdkkdDataGridViewColumn
			//
			this.uxSoGpdkkdDataGridViewColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
			this.uxSoGpdkkdDataGridViewColumn.DataPropertyName = "SoGpdkkd";
			this.uxSoGpdkkdDataGridViewColumn.HeaderText = "SoGpdkkd";
			this.uxSoGpdkkdDataGridViewColumn.Name = "uxSoGpdkkdDataGridViewColumn";
			this.uxSoGpdkkdDataGridViewColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
			this.uxSoGpdkkdDataGridViewColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
			this.uxSoGpdkkdDataGridViewColumn.ReadOnly = false;		
			//
			// uxDiaChiTtDataGridViewColumn
			//
			this.uxDiaChiTtDataGridViewColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
			this.uxDiaChiTtDataGridViewColumn.DataPropertyName = "DiaChiTt";
			this.uxDiaChiTtDataGridViewColumn.HeaderText = "DiaChiTt";
			this.uxDiaChiTtDataGridViewColumn.Name = "uxDiaChiTtDataGridViewColumn";
			this.uxDiaChiTtDataGridViewColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
			this.uxDiaChiTtDataGridViewColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
			this.uxDiaChiTtDataGridViewColumn.ReadOnly = false;		
			//
			// uxHoKhauTtDataGridViewColumn
			//
			this.uxHoKhauTtDataGridViewColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
			this.uxHoKhauTtDataGridViewColumn.DataPropertyName = "HoKhauTt";
			this.uxHoKhauTtDataGridViewColumn.HeaderText = "HoKhauTt";
			this.uxHoKhauTtDataGridViewColumn.Name = "uxHoKhauTtDataGridViewColumn";
			this.uxHoKhauTtDataGridViewColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
			this.uxHoKhauTtDataGridViewColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
			this.uxHoKhauTtDataGridViewColumn.ReadOnly = false;		
			//
			// uxParentIdDataGridViewColumn
			//
			this.uxParentIdDataGridViewColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
			this.uxParentIdDataGridViewColumn.DataPropertyName = "ParentId";
			this.uxParentIdDataGridViewColumn.HeaderText = "ParentId";
			this.uxParentIdDataGridViewColumn.Name = "uxParentIdDataGridViewColumn";
			this.uxParentIdDataGridViewColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
			this.uxParentIdDataGridViewColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
			this.uxParentIdDataGridViewColumn.ReadOnly = false;		
			//
			// uxDiaChiCtyDataGridViewColumn
			//
			this.uxDiaChiCtyDataGridViewColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
			this.uxDiaChiCtyDataGridViewColumn.DataPropertyName = "DiaChiCty";
			this.uxDiaChiCtyDataGridViewColumn.HeaderText = "DiaChiCty";
			this.uxDiaChiCtyDataGridViewColumn.Name = "uxDiaChiCtyDataGridViewColumn";
			this.uxDiaChiCtyDataGridViewColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
			this.uxDiaChiCtyDataGridViewColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
			this.uxDiaChiCtyDataGridViewColumn.ReadOnly = false;		
			//
			// uxBranchIdDataGridViewColumn
			//
			this.uxBranchIdDataGridViewColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
			this.uxBranchIdDataGridViewColumn.DataPropertyName = "BranchId";
			this.uxBranchIdDataGridViewColumn.HeaderText = "BranchId";
			this.uxBranchIdDataGridViewColumn.Name = "uxBranchIdDataGridViewColumn";
			this.uxBranchIdDataGridViewColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
			this.uxBranchIdDataGridViewColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
			this.uxBranchIdDataGridViewColumn.ReadOnly = false;		
			//
			// uxLoaiKhDataGridViewColumn
			//
			this.uxLoaiKhDataGridViewColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
			this.uxLoaiKhDataGridViewColumn.DataPropertyName = "LoaiKh";
			this.uxLoaiKhDataGridViewColumn.HeaderText = "LoaiKh";
			this.uxLoaiKhDataGridViewColumn.Name = "uxLoaiKhDataGridViewColumn";
			this.uxLoaiKhDataGridViewColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
			this.uxLoaiKhDataGridViewColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
			this.uxLoaiKhDataGridViewColumn.ReadOnly = false;		
			//
			// uxMaSoHvDataGridViewColumn
			//
			this.uxMaSoHvDataGridViewColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
			this.uxMaSoHvDataGridViewColumn.DataPropertyName = "MaSoHv";
			this.uxMaSoHvDataGridViewColumn.HeaderText = "MaSoHv";
			this.uxMaSoHvDataGridViewColumn.Name = "uxMaSoHvDataGridViewColumn";
			this.uxMaSoHvDataGridViewColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
			this.uxMaSoHvDataGridViewColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
			this.uxMaSoHvDataGridViewColumn.ReadOnly = false;		
			//
			// uxNgayDangKyDataGridViewColumn
			//
			this.uxNgayDangKyDataGridViewColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
			this.uxNgayDangKyDataGridViewColumn.DataPropertyName = "NgayDangKy";
			this.uxNgayDangKyDataGridViewColumn.HeaderText = "NgayDangKy";
			this.uxNgayDangKyDataGridViewColumn.Name = "uxNgayDangKyDataGridViewColumn";
			this.uxNgayDangKyDataGridViewColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
			this.uxNgayDangKyDataGridViewColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
			this.uxNgayDangKyDataGridViewColumn.ReadOnly = false;		
			
			// this
			this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
			this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
			this.Controls.Add(this.uxKhachHangDataGridView);
			this.Name = "KhachHangDataGridView";
			this.Size = new System.Drawing.Size(470, 300);
			((System.ComponentModel.ISupportInitialize)(this.uxKhachHangErrorProvider)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.uxKhachHangDataGridView)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.uxKhachHangBindingSource)).EndInit();
			this.ResumeLayout(false);
		}
		#endregion
				
		#region events
		
		/// <summary>
		/// Raised the CurrentEntityChanged event.
		/// </summary>
		protected void OnCurrentEntityChanged()
		{
			if (CurrentEntityChanged != null)
			{
				KhachHangDataGridViewEventArgs args = new KhachHangDataGridViewEventArgs();
				args.KhachHang = _currentKhachHang;
				CurrentEntityChanged(this, args); 
			}
		}
		
		#endregion
		
		/// <summary>
		/// Strongly typed event 
		/// </summary>
		public class KhachHangDataGridViewEventArgs : System.EventArgs
		{
			private Entities.KhachHang	_KhachHang;
	
			/// <summary>
			/// the  Entities.KhachHang instance.
			/// </summary>
			public Entities.KhachHang KhachHang
			{
				get { return _KhachHang; }
				set { _KhachHang = value; }
			}	
		}
		
		/// <summary>
		/// Handles the DataError event of the uxKhachHangDataGridView control.
		/// </summary>
		/// <param name="sender">The source of the event.</param>
		/// <param name="e">The <see cref="T:System.Windows.Forms.DataGridViewDataErrorEventArgs"/> instance containing the event data.</param>
		protected void OnKhachHangDataGridViewDataError(object sender, System.Windows.Forms.DataGridViewDataErrorEventArgs e)
		{
			System.Diagnostics.Debug.WriteLine(string.Format( "{0}, {1}", e.ColumnIndex, e.RowIndex));
		}
		
		/// <summary>
		/// Handles the CellValueNeeded event of the uxKhachHangDataGridView control.
		/// </summary>
		/// <param name="sender">The source of the event.</param>
		/// <param name="e">The <see cref="T:System.Windows.Forms.DataGridViewCellValueEventArgs"/> instance containing the event data.</param>
		protected void OnKhachHangDataGridViewCellValueNeeded(object sender, System.Windows.Forms.DataGridViewCellValueEventArgs e)
		{
			switch(uxKhachHangDataGridView.Columns[e.ColumnIndex].Name)
			{
					case "uxKhachHangIdDataGridViewColumn":
						e.Value = KhachHangList[e.RowIndex].KhachHangId;
						break;
					case "uxTenKhDataGridViewColumn":
						e.Value = KhachHangList[e.RowIndex].TenKh;
						break;
					case "uxGioiTinhDataGridViewColumn":
						e.Value = KhachHangList[e.RowIndex].GioiTinh;
						break;
					case "uxNgaySinhDataGridViewColumn":
						e.Value = KhachHangList[e.RowIndex].NgaySinh;
						break;
					case "uxMaKhDataGridViewColumn":
						e.Value = KhachHangList[e.RowIndex].MaKh;
						break;
					case "uxCmndDataGridViewColumn":
						e.Value = KhachHangList[e.RowIndex].Cmnd;
						break;
					case "uxNgayCapDataGridViewColumn":
						e.Value = KhachHangList[e.RowIndex].NgayCap;
						break;
					case "uxNoiCapDataGridViewColumn":
						e.Value = KhachHangList[e.RowIndex].NoiCap;
						break;
					case "uxSoDtDkDataGridViewColumn":
						e.Value = KhachHangList[e.RowIndex].SoDtDk;
						break;
					case "uxSoDtCtyDataGridViewColumn":
						e.Value = KhachHangList[e.RowIndex].SoDtCty;
						break;
					case "uxFaxDataGridViewColumn":
						e.Value = KhachHangList[e.RowIndex].Fax;
						break;
					case "uxSoGpdkkdDataGridViewColumn":
						e.Value = KhachHangList[e.RowIndex].SoGpdkkd;
						break;
					case "uxDiaChiTtDataGridViewColumn":
						e.Value = KhachHangList[e.RowIndex].DiaChiTt;
						break;
					case "uxHoKhauTtDataGridViewColumn":
						e.Value = KhachHangList[e.RowIndex].HoKhauTt;
						break;
					case "uxParentIdDataGridViewColumn":
						e.Value = KhachHangList[e.RowIndex].ParentId;
						break;
					case "uxDiaChiCtyDataGridViewColumn":
						e.Value = KhachHangList[e.RowIndex].DiaChiCty;
						break;
					case "uxBranchIdDataGridViewColumn":
						e.Value = KhachHangList[e.RowIndex].BranchId;
						break;
					case "uxLoaiKhDataGridViewColumn":
						e.Value = KhachHangList[e.RowIndex].LoaiKh;
						break;
					case "uxMaSoHvDataGridViewColumn":
						e.Value = KhachHangList[e.RowIndex].MaSoHv;
						break;
					case "uxNgayDangKyDataGridViewColumn":
						e.Value = KhachHangList[e.RowIndex].NgayDangKy;
						break;
				default:
				break;
			}
		}
		
		/// <summary>
		/// Handles the CellValuePushed event of the uxKhachHangDataGridView control.
		/// </summary>
		/// <param name="sender">The source of the event.</param>
		/// <param name="e">The <see cref="T:System.Windows.Forms.DataGridViewCellValueEventArgs"/> instance containing the event data.</param>
		protected void OnKhachHangDataGridViewCellValuePushed(object sender, System.Windows.Forms.DataGridViewCellValueEventArgs e)
		{
			switch(uxKhachHangDataGridView.Columns[e.ColumnIndex].Name)
			{
					case "uxKhachHangIdDataGridViewColumn":
						KhachHangList[e.RowIndex].KhachHangId = (System.Guid)e.Value;
						break;
					case "uxTenKhDataGridViewColumn":
						KhachHangList[e.RowIndex].TenKh = (System.String)e.Value;
						break;
					case "uxGioiTinhDataGridViewColumn":
						KhachHangList[e.RowIndex].GioiTinh = (System.String)e.Value;
						break;
					case "uxNgaySinhDataGridViewColumn":
						KhachHangList[e.RowIndex].NgaySinh = (System.DateTime?)e.Value;
						break;
					case "uxMaKhDataGridViewColumn":
						KhachHangList[e.RowIndex].MaKh = (System.String)e.Value;
						break;
					case "uxCmndDataGridViewColumn":
						KhachHangList[e.RowIndex].Cmnd = (System.String)e.Value;
						break;
					case "uxNgayCapDataGridViewColumn":
						KhachHangList[e.RowIndex].NgayCap = (System.DateTime?)e.Value;
						break;
					case "uxNoiCapDataGridViewColumn":
						KhachHangList[e.RowIndex].NoiCap = (System.String)e.Value;
						break;
					case "uxSoDtDkDataGridViewColumn":
						KhachHangList[e.RowIndex].SoDtDk = (System.String)e.Value;
						break;
					case "uxSoDtCtyDataGridViewColumn":
						KhachHangList[e.RowIndex].SoDtCty = (System.String)e.Value;
						break;
					case "uxFaxDataGridViewColumn":
						KhachHangList[e.RowIndex].Fax = (System.String)e.Value;
						break;
					case "uxSoGpdkkdDataGridViewColumn":
						KhachHangList[e.RowIndex].SoGpdkkd = (System.String)e.Value;
						break;
					case "uxDiaChiTtDataGridViewColumn":
						KhachHangList[e.RowIndex].DiaChiTt = (System.String)e.Value;
						break;
					case "uxHoKhauTtDataGridViewColumn":
						KhachHangList[e.RowIndex].HoKhauTt = (System.String)e.Value;
						break;
					case "uxParentIdDataGridViewColumn":
						KhachHangList[e.RowIndex].ParentId = (System.Guid)e.Value;
						break;
					case "uxDiaChiCtyDataGridViewColumn":
						KhachHangList[e.RowIndex].DiaChiCty = (System.String)e.Value;
						break;
					case "uxBranchIdDataGridViewColumn":
						KhachHangList[e.RowIndex].BranchId = (System.Guid?)e.Value;
						break;
					case "uxLoaiKhDataGridViewColumn":
						KhachHangList[e.RowIndex].LoaiKh = (System.Int16?)e.Value;
						break;
					case "uxMaSoHvDataGridViewColumn":
						KhachHangList[e.RowIndex].MaSoHv = (System.String)e.Value;
						break;
					case "uxNgayDangKyDataGridViewColumn":
						KhachHangList[e.RowIndex].NgayDangKy = (System.DateTime?)e.Value;
						break;
				default:
				break;
			}
		}
	}
}
